/**
 * Copyright (C), 2015, 上海赛可电子商务有限公司
 * Author:   康明飞
 * Date:     2016-5-31
 * Description: 通用的js逻辑
 */
;(function(){
	var suggestNode = document.getElementById("attendSymbol"),
		recommendItem = '',
		oSearchFormInput = $("#attendSymbol"),
		oSearchFormRecommend = $(".recommend-cont");
	$.ajax({
		url:'/mall/hotSearch.htm',
		type:'get',
		dataType:'json',
		success:function(data){
			if(suggestNode){
				var arg = {
				    text: "输入你要购买的车型、品牌",
				    header: null,
				    body: ["searchWord"],
				    max: 10,
				    target: "_self",
				    dataurl: "/mall/searchNotice.htm?prefix={#KEY}&jsonP={#NAME}",
				    hotSearchList: data,
				    callback: function(arg) {}
				};
				
				data = data || {};
				
				$.each(data,function(key,val){
					if(key < 3){
						recommendItem += "<a href='/multisearch/search.htm?cat=1&kwd="+encodeURI(data[key].searchWord)+"' target='_blank' ca='v160630_cm-home_pc_site-header_c"+(key+1)+"$"+data[key].searchWord+"$"+window.caCityId+"'>"+data[key].searchWord+"</a>";
					}
				});
				oSearchFormRecommend.html(recommendItem);

				new MallSuggest("attendSymbol", arg);//搜索联想功能调用

				

				oSearchFormInput.on("focus",function(){
					oSearchFormRecommend.hide();
				});

				oSearchFormInput.on("blur",function(){
					if(oSearchFormInput.val()==="" || oSearchFormInput.val() == arg.text){
						oSearchFormRecommend.show();
					}
				});
			}
		}
	});

	function showSideScreen(){
	        $(".js_not_index").hover(function() {
	            $(".fast-screen").show();
	            $(".dropdown .i-down").addClass("i-up").removeClass("i-down");
	        }, function() {
	            $(".fast-screen").hide();
	            $(".dropdown .i-up").addClass("i-down").removeClass("i-up");
	        });
	}
	showSideScreen();
})();
